package cqrtplm.dto.thirdPartyAPI;

import cn.hutool.core.collection.IterUtil;
import cqrtplm.entity.DspfMbomDetailDO;
import cqrtplm.entity.RtCfgBomDO;
import cqrtplm.entity.RtCfgStatusInfoDO;
import lombok.Data;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * @description:sap BOM数据导入实体类
 * @author: zhengxiong.jiang
 * @createDate: 2025-09-23
 * @version: 1.0
 */
@Data
public class RestAdapterBomDTO {

    //请求参数
    private InTab IN_TAB;

    //状态 (S成功;E失败)
    private String MSGTY;

    //执行结果
    private String MSGTXT;

    @Data
    public static class InTab {

        private List<InData> item;

    }

    @Data
    public static class InData {
        //工厂*
        private String WERKS;
        //成品码
        private String MATNR;
        //BOM行号 (100为第一行)
        private String POSNR;
        //物料编码*
        private String IDNRK;
        //数量* (5位小数,实际输入*100,如BOM实际搭建数量为1,传SAP时数据为100)
        private BigDecimal MENGE;
        //物料单位*
        private String MEINS;
        //段号 (段号编码加段号名称,如E010|箱体)
        private String POTX1;

        public InData(){

        }

        public InData(RtCfgStatusInfoDO infoDO, DspfMbomDetailDO detailDO, Map<String, List<String>> ibaAttributeMap){
            this.WERKS = infoDO.getScgc();
            this.MATNR = infoDO.getZmchengbom();
            this.IDNRK = detailDO.getMaterialcode();
//            this.MENGE = new BigDecimal(detailDO.getMaterialcount());
            List<String> mentList = ibaAttributeMap.get("DefaultUnitMeasurement");
            if(IterUtil.isNotEmpty(mentList)){
                this.MEINS = mentList.get(0);
            }
            this.POTX1 = detailDO.getPositionnum()+"|"+detailDO.getAssemblyposition();
        }

    }


}
